From: Robin Pepermans Date: Sun, 18 Dec 2011 17:58:47 +0000 (+0000) Subject: Follow-up r106559: it's better to set the preference for own MediaWiki names in Langu... X-Git-Tag: 1.31.0-rc.0~25905 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=e9033cbf822c3d6c36eef6c55f7ec2c43426c2c0;p=lhc%2Fweb%2Fwiklou.git Follow-up r106559: it's better to set the preference for own MediaWiki names in Language::getTranslatedLanguageNames. More consistent and saves some code :) Also update Babel to use that function. --- diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 25278e9788..6f1bb509bf 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -609,21 +609,8 @@ class CoreParserFunctions { */ static function language( $parser, $code = '', $inLanguage = '' ) { $code = strtolower( $code ); - $inLanguage = strtolower( $inLanguage ); - - if( $inLanguage === $code || $inLanguage === '' ) { - # Make sure the output is the same when the second parameter - # is the same language - global $wgContLang; - $name = $wgContLang->getLanguageName( $code ); - if( $name !== '' ) { - return $name; - } else { - # Try if there is a language name below - $inLanguage = $code; - } - } - + # default to native language name + $inLanguage = $inLanguage !== '' ? strtolower( $inLanguage ) : $code; $names = Language::getTranslatedLanguageNames( $inLanguage ); return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code ); } diff --git a/languages/Language.php b/languages/Language.php index 9b201c8d66..2eb66aae16 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -682,8 +682,12 @@ class Language { $names = array(); wfRunHooks( 'LanguageGetTranslatedLanguageNames', array( &$names, $code ) ); - foreach ( self::getLanguageNames() as $code => $name ) { - if ( !isset( $names[$code] ) ) $names[$code] = $name; + foreach ( self::getLanguageNames() as $code2 => $name ) { + # Prefer own MediaWiki native name, + # for other names just add if not added through the hook + if ( $code === $code2 || !isset( $names[$code2] ) ) { + $names[$code2] = $name; + } } return $names;